/* Master.do *******************************************************************

	Master file that runs the BPS PreK Project codebase

*******************************************************************************/

* Settings
clear all
set more off
set maxvar 32000
set matsize 11000
set trace off
set tracedepth 1
pause on

* Paths
global code		 		"A:/bps_prek/`c(username)'/code/"
adopath + 				"A:/bps_prek/`c(username)'/code/ado/personal"
set_paths

* Switches to run code
local cleaning 					1
	local a_gen_prelim_data 			1
	local b_gen_match_data	 			1
	local c_clean_nsc_data	 			1
	local d_clean_test_data				1
	local e_school_chars					1
	local f_head_start						1

local match_rdmd 				1
	local a_soda_match 					1
	local b_gen_prob_asgn 			1
	local c_gen_pscore 					1

local analysis_prep 		1
	local a_nsc_match	 							1
	local b_SASID_master_gen 				1
	local d_SIMS_panel_create				1
	local e_fin_analysis_prep				1

local analysis 					1
	local a_balance								1
	local b_nsc										1
	local c_sims									1
	local d_tests									1
	local e_subgroup							1
	local f_T8_row_joint_pvals		1
	local g_T8_col_joint_pvals		1
	local h_prek_substitution			1
	local i_post_attrit_bal				1

local figure_gen	 			1
	local a_fig1									1
	local b_figA1_psc_hist				1

local data_appendix 		1
	local sample_constr						1
	local test_attr								1
	local followup_rates					1

local z_combine_results 				1

if `cleaning' == 1 {
	if `a_gen_prelim_data' == 1					do "${code}/0_Data_Prep/a_gen_prelim_data.do"
	if `b_gen_match_data' == 1					do "${code}/0_Data_Prep/b_gen_match_data.do"
	if `c_clean_nsc_data' == 1					do "${code}/0_Data_Prep/c_clean_nsc_data.do"
	if `d_clean_test_data' == 1					do "${code}/0_Data_Prep/d_clean_test_data.do"
	if `e_school_chars' == 1						do "${code}/0_Data_Prep/e_school_chars.do"
	if `f_head_start' == 1 							do "${code}/0_Data_Prep/f_head_start.do"
}

if `match_rdmd' == 1 {
	if `a_soda_match' == 1							do "${code}/1_Match_RDMD/a_soda.do"
	if `b_gen_prob_asgn' == 1						do "${code}/1_Match_RDMD/b_gen_asnprob.do"
	if `c_gen_pscore' == 1							do "${code}/1_Match_RDMD/c_gen_pscores.do"
}

if `analysis_prep' == 1 {
	if `a_nsc_match' == 1								do "${code}/2_Analysis_Prep/a_nsc_match.do"
	if `b_SASID_master_gen' == 1				do "${code}/2_Analysis_Prep/b_SASID_master_gen.do"
	if `d_SIMS_panel_create' == 1				do "${code}/2_Analysis_Prep/d_SIMS_panel_create.do"
	if `e_fin_analysis_prep' == 1				do "${code}/2_Analysis_Prep/e_fin_analysis_prep.do"
}

if `analysis' == 1 {
	if `a_balance' == 1									do "${code}/3_Analysis/a_balance.do"
	if `b_nsc' == 1											do "${code}/3_Analysis/b_nsc.do"
	if `c_sims' == 1										do "${code}/3_Analysis/c_sims.do"
	if `d_tests' == 1										do "${code}/3_Analysis/d_tests.do"
	if `e_subgroup' == 1								do "${code}/3_Analysis/e_subgroup.do"
	if `f_T8_row_joint_pvals' == 1 			do "${code}/3_Analysis/f_T8_row_joint_pvals.do"
	if `g_T8_col_joint_pvals' == 1 			do "${code}/3_Analysis/g_T8_col_joint_pvals.do"
	if `h_prek_substitution' == 1 			do "${code}/3_Analysis/h_prek_substitution.do"
	if `i_post_attrit_bal' == 1 				do "${code}/3_Analysis/i_bal_post_attrit.do"
	}

if `figure_gen' == 1 {
	if `a_fig1' == 1 										do "${code}/3a_Figures/a_fig1.do"
	if `b_figA1_psc_hist' == 1 					do "${code}/3a_Figures/b_figA1_psc_hist.do"
}

if `data_appendix' == 1 {
	if `sample_constr' == 1							do "${code}/4_Data_Appendix/a_sample_construction.do"
	if `test_attr' == 1 								do "${code}/4_Data_Appendix/b_test_attrition.do"
	if `followup_rates' == 1						do "${code}/4_Data_Appendix/c_followup_rates.do"
}

if `z_combine_results' == 1						do "${code}/3_Analysis/z_combine_results.do"
